import { ref, onMounted, onBeforeUnmount } from "vue"

export default () => {
    const left = ref(0)
    const top = ref(0)
    const setPosition = (e: any) => {
        left.value = e.pageX
        top.value = e.pageY
    }
    onMounted(() => {
        window.addEventListener('mousemove', setPosition)
    })
    onBeforeUnmount(() => {
        window.removeEventListener('mousemove', setPosition)
        console.log('unmounted mousemove')
    })
    return {
        left,
        top
    }
}